import tkinter as tk
from tkinter import ttk, messagebox
from exam3_3_1 import create_gui as train_model_gui  # 模型训练
from exam3_3_3 import main as test_model_gui  # 模型测试
from exam3_3_2 import create_gui as user_predict_gui  # 用户预测


class MainWindow:
    def __init__(self, root):
        self.root = root
        self.root.title("乳腺癌分类系统 - 主界面")
        self.root.geometry("800x600")

        # 创建菜单栏
        menubar = tk.Menu(root)
        root.config(menu=menubar)

        # 添加“模型”菜单
        model_menu = tk.Menu(menubar, tearoff=0)
        menubar.add_cascade(label="模型", menu=model_menu)
        model_menu.add_command(label="生成模型", command=self.open_train_window)
        model_menu.add_command(label="模型测试", command=self.open_test_window)
        model_menu.add_command(label="用户预测", command=self.open_predict_window)

        # 欢迎信息
        welcome_label = tk.Label(
            root,
            text="欢迎使用乳腺癌分类预测系统\n请选择上方菜单开始操作",
            font=("微软雅黑", 16),
            justify="center"
        )
        welcome_label.pack(pady=150)

    def open_train_window(self):
        """打开模型训练窗口"""
        train_window = tk.Toplevel(self.root)
        train_model_gui_window = train_model_gui()
        # 修改窗口为嵌入模式
        train_model_gui_window.root = train_window
        train_model_gui_window.create_gui()

    def open_test_window(self):
        """打开模型测试窗口"""
        test_window = tk.Toplevel(self.root)
        test_model_gui_window = test_model_gui()
        # 修改窗口为嵌入模式
        test_model_gui_window.root = test_window
        test_model_gui_window.main()

    def open_predict_window(self):
        """打开用户预测窗口"""
        predict_window = tk.Toplevel(self.root)
        user_predict_gui_window = user_predict_gui()
        # 修改窗口为嵌入模式
        user_predict_gui_window.root = predict_window
        user_predict_gui_window.create_gui()


if __name__ == "__main__":
    root = tk.Tk()
    app = MainWindow(root)
    root.mainloop()
